<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改角色')" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-role-edit" th:object="${cmsProInfo}">
        <input id="pid" name="pid" type="hidden" th:field="*{pid}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label ">项目名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="pname" id="pname" th:field="*{pname}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">订单编号：</label>
            y
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">项目负责人：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="head" id="head" th:field="*{head}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">项目金额：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="pmoney" id="pmoney" th:field="*{pmoney}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">项目周期：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="pcycle" id="pcycle" th:field="*{pcycle}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">订单类别：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="ptype" id="ptype" th:field="*{ptype}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">客户信息：</label>
        </div>

        <div class="form-inline">
            <div class="form-group">
                <label class="col-sm-3 control-label ">客户编号：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="ccode" id="ccode" th:field="*{ccode}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">客户公司名称：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="ccompany" id="ccompany" th:field="*{ccompany}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">客户类型：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="ckind" id="ckind" th:field="*{ckind}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">客户：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="customer" id="customer" th:field="*{customer}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">职位：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="cposition" id="cposition" th:field="*{cposition}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">电话：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="cphone" id="cphone" th:field="*{cphone}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">备注：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="cdesc" id="cdesc" th:field="*{cdesc}" required>
                </div>
            </div>

        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">订单信息-项目内容：</label>
        </div>

        <div class="form-inline">
            <div class="form-group">
                <label class="col-sm-3 control-label ">项目内容：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="pcontent" id="pcontent" th:field="*{pcontent}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">项目风格：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="pstyle" id="pstyle" th:field="*{pstyle}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">项目类型：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="pkind" id="pkind" th:field="*{pkind}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">项目订立时间：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="createtime" id="createtime" th:field="*{createtime}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">完成时间：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="endtime" id="endtime" th:field="*{endtime}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">备注：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="pdesc" id="pdesc" th:field="*{pdesc}" required>
                </div>
            </div>


        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">订单信息—产品清单（零售、工程订单）：</label>
        </div>

        <div class="form-inline">
            <div class="form-group">
                <label class="col-sm-3 control-label ">产品编号：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="tcode" id="tcode" th:field="*{tcode}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">产品名称：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="tname" id="tname" th:field="*{tname}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">数量：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="tnum" id="tnum" th:field="*{tnum}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">单位：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="tunit" id="tunit" th:field="*{tunit}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">单价：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="unitprice" id="unitprice" th:field="*{unitprice}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">总额：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="ttotal" id="ttotal" th:field="*{ttotal}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">备注：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="tdesc" id="tdesc" th:field="*{tdesc}" required>
                </div>
            </div>

        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">附加信息：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="ps" id="ps" th:field="*{ps}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">客户资料：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="cinfo" id="cinfo" th:field="*{cinfo}" required>
            </div>
        </div>


    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<script type="text/javascript">
    $(function() {
        var url = ctx + "system/menu/roleMenuTreeData?roleId=" + $("#roleId").val();
        var options = {
            id: "menuTrees",
            url: url,
            check: { enable: true },
            expandLevel: 0
        };
        $.tree.init(options);
    });

    $("#form-role-edit").validate({
        onkeyup: false,
        rules:{
            roleName:{
                remote: {
                    url: ctx + "system/role/checkRoleNameUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "roleId": function() {
                            return $("#roleId").val();
                        },
                        "roleName": function() {
                            return $.common.trim($("#roleName").val());
                        }
                    },
                    dataFilter: function(data, type) {
                        return $.validate.unique(data);
                    }
                }
            },
            roleKey:{
                remote: {
                    url: ctx + "system/role/checkRoleKeyUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "roleId": function() {
                            return $("#roleId").val();
                        },
                        "roleKey": function() {
                            return $.common.trim($("#roleKey").val());
                        }
                    },
                    dataFilter: function(data, type) {
                        return $.validate.unique(data);
                    }
                }
            },
            roleSort:{
                digits:true
            },
        },
        messages: {
            "roleName": {
                remote: "角色名称已经存在"
            },
            "roleKey": {
                remote: "角色权限已经存在"
            }
        },
        focusCleanup: true
    });

    function edit() {
        var roleId = $("input[name='roleId']").val();
        var roleName = $("input[name='roleName']").val();
        var roleKey = $("input[name='roleKey']").val();
        var roleSort = $("input[name='roleSort']").val();
        var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
        var remark = $("input[name='remark']").val();
        var menuIds = $.tree.getCheckedNodes();
        $.ajax({
            cache : true,
            type : "POST",
            url : ctx + "system/role/edit",
            data : {
                "roleId": roleId,
                "roleName": roleName,
                "roleKey": roleKey,
                "roleSort": roleSort,
                "status": status,
                "remark": remark,
                "menuIds": menuIds
            },
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                $.operate.successCallback(data);
            }
        });
    }

    function submitHandler() {
        if ($.validate.form()) {
            edit();
        }
    }
</script>
</body>
</html>
